/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2024 All Rights Reserved.
 */
package com.alipay.demo.vo;

import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayResponse;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
 * @author jishupei.jsp
 * @version : OpenResponse, v0.1 2024年03月26日 7:59 下午 jishupei.jsp Exp $
 */
public class OpenResponse<E extends Object> implements Serializable {
    private static final long serialVersionUID = 8943991234L;

    private String code;

    private String msg;

    private String subCode;

    private String subMsg;

    private E data;

    public OpenResponse() {
    }

    public OpenResponse(AlipayResponse response) {
        this.code = response.getCode();
        this.msg = response.getMsg();
        this.subCode = response.getSubCode();
        this.subMsg = response.getSubMsg();
    }

    public OpenResponse(AlipayApiException e) {
        this.code = "ALIPAY_SDK_ERROR";
        this.msg = "支付宝SDK调用异常";
        this.subCode = e.getErrCode();
        this.subMsg = StringUtils.defaultIfBlank(e.getErrMsg(), e.getMessage());
    }

    /**
     * Getter method for property <tt>code</tt>.
     *
     * @return property value of code
     */
    public String getCode() {
        return code;
    }

    /**
     * Setter method for property <tt>code</tt>.
     *
     * @param code value to be assigned to property code
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * Getter method for property <tt>msg</tt>.
     *
     * @return property value of msg
     */
    public String getMsg() {
        return msg;
    }

    /**
     * Setter method for property <tt>msg</tt>.
     *
     * @param msg value to be assigned to property msg
     */
    public void setMsg(String msg) {
        this.msg = msg;
    }

    /**
     * Getter method for property <tt>subCode</tt>.
     *
     * @return property value of subCode
     */
    public String getSubCode() {
        return subCode;
    }

    /**
     * Setter method for property <tt>subCode</tt>.
     *
     * @param subCode value to be assigned to property subCode
     */
    public void setSubCode(String subCode) {
        this.subCode = subCode;
    }

    /**
     * Getter method for property <tt>subMsg</tt>.
     *
     * @return property value of subMsg
     */
    public String getSubMsg() {
        return subMsg;
    }

    /**
     * Setter method for property <tt>subMsg</tt>.
     *
     * @param subMsg value to be assigned to property subMsg
     */
    public void setSubMsg(String subMsg) {
        this.subMsg = subMsg;
    }

    /**
     * Getter method for property <tt>data</tt>.
     *
     * @return property value of data
     */
    public E getData() {
        return data;
    }

    /**
     * Setter method for property <tt>data</tt>.
     *
     * @param data value to be assigned to property data
     */
    public void setData(E data) {
        this.data = data;
    }
}
